export default (fields, formData, vm) => {
	let valid = true;
	//表单验证
	for (let key in fields) {
		//空值验证
		if (!formData[key] && fields[key].required) {
			uni.showToast({
				title: fields[key].title + vm.$t("不能为空"),
				icon: "none"
			})
			valid = false
			break
		}
		if (fields[key].min || fields[key].max) {
			const val = fields[key].type == 'number' ? Number(formData[key]) : String(formData[key]).length
			//验证
			if (val < fields[key].min) {
				uni.showToast({
					title: fields[key].title + vm.$t(`不能小于`) + fields[key].min,
					icon: "none"
				})
				valid = false
				break
			}
			//验证
			if (val > fields[key].max) {
				uni.showToast({
					title: fields[key].title + vm.$t(`不能大于`) + fields[key].max,
					icon: "none"
				})
				valid = false
				break
			}
		}

	}
	return valid
}